let href = location.href;
function getUrldata(url) {
    let reg = /^[^\s]+\?([^&\s\d]+=[^\s]+)*/
    let match = reg.exec(url)[1];
    if (!match) {//表示没匹配到
        console.warn("没有匹配到相应的query参数")
        return null
    }
    var queryArr = match.split("=");
    var queryobj = {};
    queryobj[queryArr[0]] = queryArr[1];
    return queryobj;
}

let qr = getUrldata(href);
let productid = Number(qr.productid);
var url;
if (productid < 20) {
    url = "http://chst.vip:1234/api/getinlanddiscount"
} else {
    url = "http://chst.vip:1234/api/getmoneyctrlproduct"
}
$.ajax({
    url: url,
    type: "Get",
    data: {
        productid
    }
}).then(res => {
    console.log(res);
    var item;
    if (productid < 20) {
        item = res.result[productid]
    } else {
        item = res.result[0]
    }
    if (productid < 20) {
        var html = `
    <h4>${item.productName}</h4>
    <p class="other">
        <span>${item.productFrom}|${item.productTime}</span>
        <span>${item.productTips}</span>
    </p>
    <div class="content">
        ${item.productInfo}
    </div>
    <div class="bigimggn">
        ${item.productImg}
    </div>
    <section class="gobuy">
        <a href="#">前往购买</a>
    </section>
    <section class="erweima">
        <img src="http://chst.vip:8081/mmb/images/mmbweixin2.png" alt="">
    </section>
    ${item.productComment}
    `
    } else {
        var html = `
        <h4>${item.productName}</h4>
        <p class="other"><span>${item.productFrom}|${item.productTime}</span><span>${item.productTips}</span></p>
        <div class="content">
            ${item.productImgSm}
            ${item.productInfo}
        </div>
        <div class="bigimg">
            ${item.productImgSm}
        </div>
        ${item.productCity}
        <section class="gobuy">
            <a href="#">前往购买</a>
        </section>
        <section class="erweima">
            <img src="http://chst.vip:8081/mmb/images/mmbweixin2.png" alt="">
        </section>
        ${item.productComment}
        `
    }
    $("main").html(html)
})